Skip to content

releaser: add CloudFront Function + KVS redirect path (lab)#25047

Open
dvdksn wants to merge 2 commits into
docker:mainfrom
dvdksn:redirs
Open

releaser: add CloudFront Function + KVS redirect path (lab)#25047
dvdksn wants to merge 2 commits into
docker:mainfrom
dvdksn:redirs

Conversation

@dvdksn
Copy link
Copy Markdown
Contributor

@dvdksn dvdksn commented May 13, 2026

Summary

Replaces the Lambda@Edge redirect handler with a CloudFront Function backed by a CloudFront KeyValueStore (KVS). The function does an O(1) kvs.get(uri) lookup instead of iterating an inlined redirect map, at ~1/6 the per-request cost of Lambda@Edge.

  • hack/releaser/cloudfront-function-redirects.js — KVS lookup → inline prefix loop → markdown content negotiation. ~3.5 KB, under the 10 KB limit.
  • hack/releaser/aws_kvs.go — new aws cloudfront-function-update subcommand. Diffs redirects.json against current KVS contents, applies changes in batches of 50 via UpdateKeys, then UpdateFunction + PublishFunction (skipped if LIVE is unchanged).
  • Dockerfile stage + bake target + PR dry-run check in build.yml.
  • env.json: two new fields (DOCS_CLOUDFRONT_KVS_ARN, DOCS_CLOUDFRONT_FUNCTION_NAME) per ref; the new deploy step is gated on both being non-empty.

Lab vars are now populated. Prod stays on Lambda@Edge until those fields are filled in for refs/heads/main.

Related

  • docker/infra-terraform#12107 — KVS resource
  • docker/infra-terraform#12109 — CloudFront Function + distribution swap (merged)

Test plan

  • DRY_RUN=true releaser aws cloudfront-function-update ... — loads redirects, normalizes keys, renders the function template
  • PR build workflow green
  • Successful KVS sync + function publish on next push to lab
  • Sample redirects on docs-labs.docker.com return 301 with the right Location (exact-match, prefix-strip, prefix-no-strip)
  • Accept: text/markdown returns the .md variant

Adds a second redirect path that uses a CloudFront Function backed by
a CloudFront KeyValueStore (KVS) instead of Lambda@Edge: O(1)
kvs.get(uri) per request instead of iterating the whole redirect map.

Wired to the lab environment via two new env vars
(DOCS_CLOUDFRONT_KVS_ARN, DOCS_CLOUDFRONT_FUNCTION_NAME) on the
existing refs/heads/lab and refs/heads/main entries. The new deploy
step is gated on both being non-empty, so prod stays Lambda@Edge-only
until those vars are populated.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 13, 2026

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit d34246d
🔍 Latest deploy log https://app.netlify.com/projects/docsdocker/deploys/6a047c1e2c96cd0008e4154f
😎 Deploy Preview https://deploy-preview-25047--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added area/release Relates to CI or deployment area/config ci ci updates labels May 13, 2026
Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

This PR adds a new CloudFront Function + KVS redirect path for the staging environment. All changed files are infrastructure and tooling (CI workflows, Go source, JavaScript CloudFront function, Dockerfile, bake config, env.json) — no markdown documentation pages were added, removed, or moved.

Checks passed:

  • No vendored or generated data files touched
  • No documentation pages removed or moved (no missing redirects)
  • No user-facing documentation text with style violations
  • No front matter or Hugo shortcode issues

@dvdksn dvdksn changed the title releaser: add CloudFront Function + KVS redirect path (stage) releaser: add CloudFront Function + KVS redirect path (lab) May 13, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread hack/releaser/go.mod
@@ -5,9 +5,25 @@ go 1.26.0
require (
github.com/alecthomas/kong v1.4.0
github.com/aws/aws-sdk-go v1.55.5
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a follow-up, we should look at replacing the remaining v1 uses to v2 as well;

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudfront"
"github.com/aws/aws-sdk-go/service/lambda"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I haven't looked at these much at all lately 🙈

@dvdksn dvdksn marked this pull request as ready for review May 13, 2026 14:23
@dvdksn dvdksn requested review from crazy-max and thaJeztah May 13, 2026 14:23
Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟡 NEEDS ATTENTION

This PR introduces a new CloudFront Function + KVS redirect system. The CI/workflow changes and Go infrastructure look well-structured. One confirmed logic bug in the CloudFront Function JS and two medium-severity concerns in the Go code need attention before this is wired to production.

Comment thread hack/releaser/cloudfront-function-redirects.js
Comment thread hack/releaser/aws_kvs.go
Comment thread hack/releaser/aws_kvs.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config area/release Relates to CI or deployment ci ci updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants